package cjgl.service;

import java.util.List;

import cjgl.dao.GradeDAO;
import cjgl.entity.Course;
import cjgl.entity.Grade;

public class GradeService {
	private GradeDAO gradeDAO = new GradeDAO();
	public Grade findById(Integer id) {
		return gradeDAO.findById(id);
	}

	public List<Grade> findAll() {
		return gradeDAO.findAll();
	}

	public void delete(Integer id) {
		gradeDAO.delete(id);
	}
	
	public void save(Grade grade) {
		Integer id = grade.getId();
		if(id==null) {
			gradeDAO.insert(grade);
		}else{
			gradeDAO.update(grade);
		}
	}
	
	public void delete(Grade grade) {
		gradeDAO.delete(grade.getId());
	}

	public List<Grade> findByStuId(Integer stuId) {
		return gradeDAO.findByStuId(stuId);
	}

	public Grade findByStuIdAndKcId(Integer id, Integer kcId) {
		return gradeDAO.findByStuIdAndKcId(id,kcId);
	}


	public List<Course> findCourseByBjId(Integer bjId) {
		return gradeDAO.findCourseByBjId(bjId);
	}

	public List<List<Object>> getCjb(Integer bjId, List<Course> courses) {
		
		return gradeDAO.getCjb(bjId,courses);
	}
}
